package com.xinyun.traceability.enity.dto;


import com.github.pagehelper.Page;

import java.io.Serializable;

/**
 * 分页查询条件
 */
public class PageableQueryObject implements Serializable {

    /**
     * 页数 默认第一页
     */
    private int page = 1;

    /**
     * 页容量
     */
    private int limit = Integer.valueOf("15");

    /**
     * 总页数
     */
    private int totalPages;

    public PageableQueryObject() {
    }

    public PageableQueryObject(int page, int pageSize) {
        this.page = page;
        this.limit = pageSize;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public Page getPageable() {
        if (this.page > 0 && this.limit > 0) {
            return new Page(this.page - 1, this.limit);
        } else {
            return new Page(0, this.limit);
        }
    }

}
